<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>缺陷单</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link href="../../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../../css/mui.picker.min.css" />
		<link rel="stylesheet" href="../../css/allApp.css" />
		<link rel="stylesheet" href="css/qxd.css" />

	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">缺陷单</h1>
		</header>
		<div class="mui-content">
			<div id="slider" class="mui-slider">
				<div id="sliderSegmentedControl" class="mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<a class="mui-control-item mui-active" href="#item1mobile">
						基本信息
					</a>
					<a class="mui-control-item" href="#item2mobile">
						操作内容
					</a>

				</div>
				<div class="mui-slider-group">
					<div id="item1mobile" class="mui-slider-item mui-control-content mui-active">
						<div id="scroll1" class="mui-scroll-wrapper">
							<div class="mui-scroll">
								<div class="jb_row">
									<div class="mui-input-row">
										<label class="jbLeft1">单号：</label>
										<input type="text" class="jbRight1 work_number" placeholder="">
									</div>
									<div class="mui-input-row">
										<label class="jbLeft1">描述：</label>
										<input type="text" placeholder="" class="jbRight1 description">
									</div>
									<div class="mui-input-row">
										<label class="jbLeft1">状态：</label>
										<input type="text" class="jbRight1 red stage" placeholder="">
									</div>
									<div class="mui-input-row">
										<label class="jbLeft1">报告者：</label>
										<input type="text" class="jbRight1 reporter" placeholder="">
									</div>
									<!--<div class="jb_line">
										<div class="jbLeft1">单号：</div>
										<div class="jbRight1 work_number">4206000078965</div>
									</div>-->
									<!--<div class="jb_line">
										<div class="jbLeft1">描述：</div>
										<div class="jbRight1 description">1号丰体PT版温度高</div>
									</div>
									<div class="jb_line">
										<div class="jbLeft1">状态：</div>
										<div class="jbRight1 red stage">检修负责人分配工作或者工作负责人处理</div>
									</div>
									<div class="jb_line">
										<div class="jbLeft1">报告者：</div>
										<div class="jbRight1 reporter">高深</div>
									</div>-->
								</div>
								<div class="jb_row topLine">
									<div class="mui-input-row">
										<label class="jbLeft2">风机编号：</label>
										<input type="text" class="jbRight2 fan_number" placeholder="">
									</div>
									<div class="mui-input-row">
										<label class="jbLeft2">故障代码：</label>
										<input type="text" class="jbRight2 orange error_code" placeholder="">
									</div>
									<div class="mui-input-row">
										<label class="jbLeft2">故障开始时间：</label>
										<input type="text" class="jbRight2 red start_time" placeholder="">
									</div>
									<!--<div class="jb_line">
										<div class="jbLeft2">风机编号：</div>
										<div class="jbRight2 fan_number">F0018杜尔伯特风电场18机房</div>
									</div>-->
									<!--<div class="jb_line">
										<div class="jbLeft2">故障代码：</div>
										<div class="jbRight2 orange error_code">A001XT 扇叶故障</div>
									</div>-->
									<!--<div class="jb_line">
										<div class="jbLeft2">故障开始时间：</div>
										<div class="jbRight2 red start_time">2017-12-23 12:00:00</div>
									</div>-->

								</div>
								<div class="jb_row topLine">
									<div class="jb_line">
										<div class="jbLeft3">下一环节负责人（状态描述）：</div>
										<button class="jbRight3" id="addPeople">
											<img class="jbBtnIcon" src="img/icon1.png" />
											<span>添加</span>
										</button>
									</div>
									<textarea class="jq_line1" id="getPeople" style="padding-left: 3%;margin-bottom: 0;font-size: 14px;">

									</textarea>
								</div>
								<div class="jb_row topLine">
									<div class="jb_line">
										<div class="jbLeft3">工单：</div>
										<button class="jbRight3 ">
											<img class="jbBtnIcon" src="img/icon3.png" style="width:14px !important;top：3px"/>
											<span>编辑</span>
										</button>
									</div>
									<textarea class="jq_line1 worker_order" style="padding-left:3%;margin-bottom: 0;font-size: 14px;" readonly>09874636823776335653</textarea>
								</div>
							</div>
						</div>
					</div>
					<div id="item2mobile" class="mui-slider-item mui-control-content">
						<div id="scroll2" class="mui-scroll-wrapper">
							<div class="mui-scroll">
								<ul class="mui-table-view mui-table-view-chevron">

									<li class="mui-table-view-cell mui-collapse">
										<a class="mui-navigate-right" href="#">缺陷类型：
											<span class="mui-pull-right cz_row_span defect_type">FYBJ易损零件更换</span>
										</a>
										<!--<ul class="mui-table-view mui-table-view-chevron">
											<li class="mui-table-view-cell">
												<a class="mui-navigate-right" href="#">iOS</a>
											</li>
											<li class="mui-table-view-cell">
												<a class="mui-navigate-right" href="#">Android</a>
											</li>
											<li class="mui-table-view-cell">
												<a class="mui-navigate-right" href="#">HTML5</a>
											</li>
										</ul>-->
									</li>
									<li class="mui-table-view-cell mui-collapse">
										<a class="mui-navigate-right" href="#">停机台数：
											<span class="mui-pull-right cz_row_span number_stops">2</span>
										</a>

									</li>
								</ul>
								<div class="cz_row topLine">
									<div class="mui-input-row">
										<label class="jbLeft2">故障开始时间：</label>
										<input type="text" class="jbRight2 replace_part" placeholder="">
									</div>
									<div class="mui-input-row">
										<label class="jbLeft2">缺陷恢复：</label>
										<input type="text" class="jbRight2 orange defect_recovery" placeholder="">
									</div>
									<div class="mui-input-row">
										<label class="jbLeft2">故障电量（W千瓦时）：</label>
										<input type="text" class="jbRight2 falut_power" placeholder="">
									</div>
									<div class="mui-input-row">
										<label class="jbLeft2">故障损失电量（W千瓦时）：</label>
										<input type="text" class="jbRight2 falut_loss" placeholder="">
									</div>
									<div class="mui-input-row">
										<label class="jbLeft2">等待时间（小时）：</label>
										<input type="text" class="jbRight2 wait_time" placeholder="">
									</div>
									<div class="mui-input-row">
										<label class="jbLeft2">故障期间平均风速（m/s）：</label>
										<input type="text" class="jbRight2 wind_speed" placeholder="">
									</div>
									<div class="mui-input-row">
										<label class="jbLeft2">故障期间限电负荷（MV）：</label>
										<input type="text" class="jbRight2 power_load" placeholder="">
									</div>
									<div class="mui-input-row">
										<label class="jbLeft2">故障优先级：</label>
										<input type="text" class="jbRight2 orange default_priority" placeholder="">
									</div>
									<!--<div class="jb_line">
										<div class="jbLeft2">更换大部件：</div>
										<div class="jbRight2 replace_part">JCL齿轮箱</div>
									</div>-->
									<!--<div class="jb_line">
										<div class="jbLeft2">缺陷恢复：</div>
										<div class="jbRight2 orange defect_recovery">SWHF尚未恢复</div>
									</div>-->
									<!--<div class="jb_line">
										<div class="jbLeft2">故障电量（W千瓦时）：</div>
										<div class="jbRight2 falut_power">23.34</div>
									</div>-->
									<!--<div class="jb_line">
										<div class="jbLeft2">故障损失电量（W千瓦时）：</div>
										<div class="jbRight2 falut_loss">23.34</div>
									</div>
									<div class="jb_line">
										<div class="jbLeft2">等待时间（小时）：</div>
										<div class="jbRight2 wait_time">3</div>
									</div>
									<div class="jb_line">
										<div class="jbLeft2">故障期间平均风速（m/s）：</div>
										<input class="jbRight2 wind_speed">23.34
									</div>-->
									<!--<div class="jb_line">
										<div class="jbLeft2">故障期间限电负荷（MV）：</div>
										<div class="jbRight2 power_load">23.34</div>
									</div>
									<div class="jb_line">
										<div class="jbLeft2">故障优先级：</div>
										<div class="jbRight2v">8</div>
									</div>-->
								</div>
								<div class="cz_row topLine">
									<div class="jb_line">
										<div class="jbLeft3">处理情况：</div>
									</div>
									<textarea class="jb_line jq_line1 deal" style="padding-left:3%;margin-bottom: 0;font-size: 14px;">高扭是对返回时的的水分护士，但是返回岁，是度覅是不爱，说的bfUISBUI，稍等回复水，是不是保存失败，是对方不爱上班。</textarea>
								</div>
							</div>
						</div>

					</div>

				</div>
			</div>
			<footer>
				<nav class="mui-bar mui-bar-tab">
					<a id="defaultTab" class="mui-tab-item mui-active back">
						<span class="mui-icon"><img class="home_icon" src="img/footer1.png"/></span>
						<span class="mui-tab-label">回退</span>
					</a>
					<a id="defaultTab2" class="mui-tab-item">
						<span class="mui-icon "><img class="home_icon" src="img/footer3.png"//></span>
						<span class="mui-tab-label">提交</span>
					</a>
				</nav>
			</footer>

		</div>
		<script src="../../js/mui.min.js"></script>
		<script type="text/javascript" src="../../js/jquery-3.2.1.min.js"></script>
		<script src="../../js/mui.dtpicker.js"></script>
		<script src="../../js/mui.picker.min.js"></script>
		<script>
			//			localStorage.removeItem('info');
			console.log('draft/qxd.html');
			var info_clone = [];
			var info = [];
			var info_detail = {};

			var peopleStr = "";
			mui.init({
				swipeBack: false
			});
			mui.plusReady(function() {
				clickToChoose();
				getPeople();
				getData();
				back();
				chooseType();
				//				$('#defaultTab1').on('tap', function() {
				//					if(plus.networkinfo.getCurrentType() == plus.networkinfo.CONNECTION_NONE) {
				//						
				//					} else {
				//						save();
				//					}
				//				});
				//日期选择
				var dtpicker = new mui.DtPicker({
					type: "date", //设置日历初始视图模式 
					labels: ['年', '月', '日']
				});
				$('.start_time').on('tap',function(){
					var this_ = this;
					dtpicker.show(function(e) {
   						$(this_).val(e.value);
					}); 
				});
				$('.replace_part').on('tap',function(){
					var this_ = this;
					dtpicker.show(function(e) {
   						$(this_).val(e.value);
					}); 
				});
				// 点击提交 
				$('#defaultTab2').on('tap', function() {
					submit_();
				});
				// 点击编辑
				$('.edit').on('tap', function() {
					if($('.worker_order').attr('readonly') == 'readonly') {
						mui.toast('工单进入可编辑状态!');
						$('.worker_order').attr('readonly', false);
						$('.worker_order').focus();
					} else {
						mui.toast('请对工单进行编辑!');
					}

				});
			});
			mui('.mui-scroll-wrapper').scroll({
				scrollY: true, //是否竖向滚动
				scrollX: false, //是否横向滚动
				startX: 0, //初始化时滚动至x
				startY: 0, //初始化时滚动至y
				indicators: false, //是否显示滚动条
				deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏
				bounce: false //是否启用回弹
				//	deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
			});

			var sliderSegmentedControl = document.getElementById('sliderSegmentedControl');
			mui('.mui-input-group').on('change', 'input', function() {
				if(this.checked) {
					sliderSegmentedControl.className = 'mui-slider-indicator mui-segmented-control mui-segmented-control-inverted mui-segmented-control-' + this.value;
					//force repaint
					sliderProgressBar.setAttribute('style', sliderProgressBar.getAttribute('style'));
				}
			});
			$(".mui-control-content").height($(window).height() - $("#slider").height() - $(".mui-bar.mui-bar-nav").height() + 18 - 50);
			//打开选择页面
			function clickToChoose() {
				$('#addPeople').on('tap', function() {
					mui.openWindow('choose.html', 'choose.html');
				});
			}
			// 获取从选择页面选择的 人员信息
			function getPeople() {
				window.addEventListener('getPeople', function(e) {
					peopleStr = e.detail.people;
					console.log('226-----' + e.detail.people);
					$('#getPeople').val(peopleStr);
				});
			}
			function chooseType(){
				
				$('#defect_type_').on('tap','li',function(){
					$('.defect_type').text($(this).text());
					mui('#defect_type_').popover('toggle');
				});
			}
			// 保存当前信息,当有网络时,保存到待办列表; 当无网络时,保存到草稿箱
			//			function save() {
			//				mui.confirm('确认保存吗?', function(e) {
			//					if(e.index == "0") {
			//						info_detail = {
			//								work_number: $('.work_number').val(), //单号
			//								description: $('.description').val(), //描述
			//								stage: $('.stage').val(), //状态
			//								reporter: $('.reporter').val(), // 报告者
			//								fan_number: $('.fan_number').val(), //风机编号
			//								error_code: $('.error_code').val(), // 故障代码
			//								start_time: $('.start_time').val(), // 故障开始时间
			//								getPeople: $('.getPeople').val(), // 下一环节负责人
			//								worker_order: $('.worker_order').val(), // 工单
			//								defect_type: $('.defect_type').val(), // 缺陷类型
			//								number_stops: $('.number_stops').val(), // 停机台数
			//								replace_part: $('.replace_part').val(), // 故障开始时间
			//								defect_recovery: $('.defect_recovery').val(), // 缺陷恢复
			//								falut_power: $('.falut_power').val(), // 故障电量
			//								falut_loss: $('.falut_loss').val(), // 故障损失电量
			//								wait_time: $('.wait_time').val(), // 等待时间
			//								wind_speed: $('.wind_speed').val(), // 故障期间平均风速
			//								power_load: $('.power_load').val(), // 故障期间电负荷
			//								default_priority: $('.default_priority').val(), // 故障优先级
			//								deal: $('.deal').val() // 处理情况
			//						};
			//						info.push(info_detail);
			//						console.log("========="+info.length);
			//						localStorage.setItem('info', JSON.stringify(info));
			////						info_clone = localStorage.getItem('info');
			////						console.log('337----info_clone'+info_clone);
			////						info_clone.push(info_detail); // JSON对象不具备push功能
			////						localStorage.setItem('getInfo',info_clone);
			//						mui.alert("网络异常，请检查网络设置！");
			//						console.log('336-----'+JSON.stringify(info));
			//						mui.openWindow({
			//							url: '../notice/notice.html',
			//							id: 'notice.html',
			//							extras: {
			//								info: info
			//							}
			//						});
			//					}
			//				})
			//			}
			
			function back(){
				$('.back').on('tap',function(){
					$('.back').on('tap', function() {
					plus.webview.showWaiting('发起回退...');
					mui.baseApp.httpRequst('/api/v2/tzdOrder/rollback', {
						tzdId: tzdId
					}, function(data) {
						plus.webview.closeWaiting();
						if(data.status == "200") {
							console.log("回退通知单成功");
						} else if(data.status == "500") {
							mui.toast('回退通知单失败!');
						}
					}, function() {
						console.log("回退通知单失败");
						mui.toast("回退通知单失败！！！");
					});
				});
				});
			}
			
			// 加载数据
			function getData() {
				var self = plus.webview.currentWebview();
				var list = self.list;
				console.log('加载的数据-----' + JSON.stringify(list));
					$('.work_number').val(list.work_number), //单号
					$('.description').val(list.description), //描述
					$('.stage').val(list.stage), //状态
					$('.reporter').val(list.reporter), // 报告者
					$('.fan_number').val(list.fan_number), //风机编号
					$('.error_code').val(list.error_code), // 故障代码
					$('.start_time').val(list.start_time), // 故障开始时间
					$('.getPeople').val(list.getPeople), // 下一环节负责人
					$('.worker_order').val(list.worker_order), // 工单
					$('.defect_type').val(list.defect_type), // 缺陷类型
					$('.number_stops').val(list.number_stops), // 停机台数
					$('.replace_part').val(list.replace_part), // 故障开始时间
					$('.defect_recovery').val(list.defect_recovery), // 缺陷恢复
					$('.falut_power').val(list.falut_power), // 故障电量
					$('.falut_loss').val(list.falut_loss), // 故障损失电量
					$('.wait_time').val(list.wait_time), // 等待时间
					$('.wind_speed').val(list.wind_speed), // 故障期间平均风速
					$('.power_load').val(list.power_load), // 故障期间电负荷
					$('.default_priority').val(list.default_priority), // 故障优先级
					$('.deal').val(list.deal) // 处理情况
			}
			//赋值
			function assignment() {
				work_number = $('.work_number').val();
				description = $('.description').val();
				stage = $('.stage').val();
				reporter = $('.reporter').val();
				fan_number = $('.fan_number').val();
				error_code = $('.error_code').val();
				start_time = $('.start_time').val();
				getPeople_ = $('.getPeople').val();
				worker_order = $('.worker_order').val();
				defect_type = $('.defect_type').val();
				number_stops = $('.number_stops').val();
				replace_part = $('.replace_part').val();
				defect_recovery = $('.defect_recovery').val();
				falut_power = $('.falut_power').val();
				falut_loss = $('.falut_loss').val();
				wait_time = $('.wait_time').val();
				wind_speed = $('.wind_speed').val();
				power_load = $('.power_load').val();
				default_priority = $('.default_priority').val();
				deal = $('.deal').val();
			}
			//通知单提交
			function submit_() {
				assignment();
				plus.nativeUI.showWaiting('通知单提交中...');
				mui.baseApp.httpRequst('/api/v2/tzdOrder/submit', {
					tzdId: tzdId,
					nextper: getPeople_
				}, function(data) {
					plus.webview.closeWaiting();
					if(data.status == "200") {
						mui.toast('提交成功!');
					} else if(data.status == "400") {
						mui.toast('没有下一环节负责人');
						return;
					} else if(data.status == "500") {
						mui.toast('提交失败');
					}
				}, function() {
					console.log("提交失败");
					mui.toast("提交失败！！！");
				});
			}
		</script>
	</body>

</html>